/*
 * @lc app=leetcode.cn id=476 lang=javascript
 *
 * [476] 数字的补数
 */

// @lc code=start
/**
 * @param {number} num
 * @return {number}
 */
var findComplement = function(num) {
    let arr = []
    let originalStr = (num.toString(2) + '')
    for (let index = 0; index < originalStr.length; index++) {
        const e = originalStr[index];
        if (e === '1') {
            arr.push('0')
        } else {
            arr.push('1')
        }
    }
    let str = arr.join('')
    return parseInt(str, 2)
};
// @lc code=end

